﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Frontend.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Đăng ký thẻ sinh viên
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% Html.RenderPartial("Modules/Mod_Banner"); %>
    <div class="cmbox">
        <div class="ctitle">Đăng ký sở hữu Thẻ Sinh Viên</div>
        <div class="ccon">
            <%using (Html.BeginForm("Card", "Register", FormMethod.Post, new { id = "addForm", @class = "form" }))
            {%>
            <%=TempData["Message"]%>
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="edit">
                <tr>
                    <td class="label required">
                        Họ và Tên <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextBox("FullName","", new { @maxlength = "100", @style = "width:300px" }));
                                           
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label required">
                        Giới Tính <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.RadioButton("Gender", "Nam",true, new { @id = "rbMale"}));
                            Response.Write("<label for=\"rbMale\">Nam</label>&nbsp;");
                            Response.Write(Html.RadioButton("Gender", "Nữ",false, new { @id = "rbFemale" }));
                            Response.Write("<label for=\"rbFemale\">Nữ</label>");
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label required">
                        Địa Chỉ <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextArea("ContactAddress","", new { @style = "width:300px", @maxlength = "200" }));               
                        %>
                    </td>
                </tr>
                <tr >
                    <td class="label">
                        Nhận thẻ tại 
                    </td>
                    <td class="input"> 
                        <%
                            Response.Write(Html.CheckBox("chkReceive", true, new { @id = "chkReceive" }));
                            Response.Write("<label for=\"chkReceive\">&nbsp;Địa chỉ bên trên</label>");
                        %>
                    </td>
        
                </tr>
                <tr id="trReceiveAddress" style="display:none" >
                    <td class="label required">
                       Địa chỉ nhận thẻ <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextArea("ReceiveAdrress","", new { @style = "width:300px", @maxlength = "200" }));               
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label required">
                        Điện Thoại <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextBox("Phone","", new { @style = "width:300px", @maxlength = "20" }));               
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label required">
                        Email <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextBox("Email","", new { @style = "width:300px" , @maxlength = "200"}));               
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Trường học
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextBox("School","", new { @style = "width:300px", @maxlength = "200" }));               
                        %>
                    </td>
                </tr>
               <tr>
                    <td class="label required">
                        Niên khóa <span>*</span>
                    </td>
                    <td class="input">
                        <% 
                            Response.Write(Html.TextBox("SchoolYear","", new { @style = "width:300px", @maxlength = "200" }));               
                        %>
                    </td>
                </tr>
                <tr>
                    <td class="label"></td>
                    <td class="input">
                     <%
                         Response.Write(Html.CheckBox("chkAgreeName", false, new { @id = "chkAgree" }));
                         Response.Write("<label for=\"chkAgree\">&nbsp;Tôi đồng ý đóng phí phát hành thẻ 20.000đ</label>");
                        %>
                    </td>
                </tr>
                 <tr>
                    <td class="label">
                        Mã bảo vệ
                    </td>
                    <td>
                        <img src="/Mabaove" />
                    </td>
                </tr>
                <tr>
                    <td class="label required">
                        Nhập mã bảo vệ <span>*</span>
                    </td>
                    <td>
                        <input type="text" id="txtCapcha" name="txtCapcha" maxlength="10" />
                    </td>
                </tr>        
                <tr>
                    <td>
                    </td>
                    <td>
                        <input type="submit" value="Đăng ký" id="btnSave"/>
                        <input type="reset" value="Làm lại" id="btnCancel" />
                    </td>
                </tr>
            </table>
              <% } %>
        </div>
    </div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="HeadContent" runat="server">

<script type="text/javascript">
var formIndex = 0;
$(document).ready(function () {

    //add method valid fone
    jQuery.validator.addMethod(
            "validatePhone", function (value) {
                return JS_LIB.isPhone(value);
            }, 'Chỉ được nhập các ký tự : 0123456789.,()-+ ');
    $("#chkReceive").click(function () {
        isChecked = $('input[name=chkReceive]').is(':checked');

        if (isChecked) {
            $("#trReceiveAddress").css("display", "none");
            $("#ReceiveAdrress").rules("remove");
            $("#ReceiveAdrress").val('');
        } else {
            $("#trReceiveAddress").css("display", "");
            $("#ReceiveAdrress").rules("add", {
                required: true,
                maxlength: 200

            });

        }
    });
    $("#btnCancel").click(function () {
        window.location = "dang-ky-lam-thanh-vien-the-sinh-vien.html";
    });
    $("#save").click(function () {
        isChecked = $('input[name=chkAgreeName]').is(':checked');
        if (!isChecked) {
            JS_LIB.msgBox("Vui lòng nhấn \"Tôi đồng ý đóng phí phát hành thẻ 20.000đ\"", 300);
            return false;
        }
        return true;
    });
    $("#addForm").validate({
        debug: false,
        errorElement: "span",
        errorPlacement: function (error, element) {
            error.tooltip({
                bodyHandler: function () {
                    return error.html();
                }
            });
            error.insertAfter(element);
        },
        rules: {
            FullName: {
                required: true
            },
            Address: {
                required: true,
                maxlength: 255
            },
            Phone: {
                required: true,
                validatePhone: true
            },
            Email: {
                required: true,
                email: true
            },
            SchoolYear: {
                required: true

            },
            txtCapcha: {
                required: true

            }
        },
        submitHandler: function (form) {
            if (formIndex == 0) {
                form.submit();
                formIndex++;
            }
        }
    });
});

</script>
</asp:Content>
